package Day14;

import Day5.Dog;
import sun.awt.windows.ThemeReader;

/**
 * @Author kalista
 * @Description
 * @Date 2020/11/20  14:26
 **/
public class Test03 {


    public static void main(String[] args) {

        // 创建可运行代码
        MyTheard2 myTheard2 = new MyTheard2();
        // 将一个可运行的对象封装到一个线程对象中
        Thread thread = new Thread(myTheard2);

        //启动线程
        thread.start();


        System.out.println("sdfsfd");

        MyTheard3 myTheard3 = new MyTheard3();
        myTheard3.start();


    }
}


class MyTheard2  implements Runnable{

    @Override
    public void run() {


        for (int i = 0; i < 1000; i++) {
            System.out.println("MyTheard2MyTheard2" + i );
        }
    }
}

class MyTheard3 extends Thread{
    @Override
    public void run() {
        Thread.yield();

        for (int i = 0; i < 1000; i++) {
            if (i % 2 == 0){
                Thread.yield();
            }
            System.out.println("我是MyTheard3MyTheard3MyTheard3" + i);
        }
    }
}